package solution;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-04-06
 * Time: 16:47
 */
//https://leetcode.cn/problems/coin-change-ii/description/
class Solution2 {
    public int change(int amount, int[] coins) {
        int[] dp = new int[amount + 1];
        dp[0] = 1;
        ///Solution3,对比着看
        //顺序不同的序列被视作相同的组合
        //物品在外层
        for (int coin : coins) {
            for (int i = coin; i <= amount; i++) {
                dp[i] += dp[i - coin];
            }
        }
        return dp[amount];
    }
}
